<template>
    <div>
        <!--<Card :dis-hover="true" :bordered="false">-->
            <iview-table
                    ref="table"
                    :span1="16"
                    :span2="8"
                    :baseURL="queryModel.baseURL"
                    :menuId="dataModel.menuId"
                    :columns="dataModel.columns"
                    :order="dataModel.order"
                    :pageNumber="pageModel.pageNumber"
                    :pageSize="pageModel.pageSize"
                    :defaultFilters="queryModel.defaultFilters"
                    v-on="{changeTotalSize:changeTotalSize,changeSelect:changeSelect}">
            </iview-table>
            <br>
            <iview-page
                    :totalSize="pageModel.totalSize"
                    :pageNumber="pageModel.pageNumber"
                    :pageSize="pageModel.pageSize"
                    :pageSizeOpts="pageModel.pageSizeOpts"
                    v-on="{changePageNumber:changePageNumber,changePageSize:changePageSize}">
            </iview-page>
        <!--</Card>-->
    </div>
</template>

<script>
    import iviewTable from '@/view/common/table/Table.vue';
    import iviewPage from '@/view/common/page/Page.vue';
    export default {
        components: {
            iviewTable,
            iviewPage
        },
        data () {
            return {
                selectPane: '1',
                selectRows: [],
                baseURL: '/user/surgical/project',
                queryModel: {
                    // 网关代理路径(必须)+资源路径(可选)
                    baseURL: '/user/surgical/project',
                    defaultFilters: [
                    ]
                },
                dataModel: {
                    menuId: 0,
                    columns: [
                        {
                            title: '项目名称',
                            key: 'name',
                        },
                        {
                            title: '单价',
                            key: 'price',
                        },
                        {
                            title: '操作',
                            width: 150,
                            align: 'center',
                            render: (h, params) => {
                                return h('div', [
                                    h('Button', {
                                        props: {
                                            type: 'info',
                                            size: 'default'
                                        },
                                        style: {
                                            marginRight: '5px'
                                        },
                                        on: {
                                            click: () => {
                                                this.select(params.index, params.row)
                                            }
                                        }
                                    }, '选择')
                                ]);
                            }
                        }
                    ],
                    order: 'id desc'
                },
                pageModel: {
                    totalSize: 0,
                    pageNumber: 1,
                    pageSize: 10,
                    pageSizeOpts: [5, 10, 20, 50, 100]
                }
            };
        },
        methods: {
            select (index, row) {
                this.$emit('selectSurgical', row)
            },
            refresh () {
                this.$refs.table.refresh()
            },
            changeSelect (rows) {
                this.selectRows = rows
            },
            changeTotalSize (totalSize) {
                this.pageModel.totalSize = totalSize
            },
            changePageNumber (pageNumber) {
                this.pageModel.pageNumber = pageNumber
            },
            changePageSize (pageSize) {
                this.pageModel.pageSize = pageSize
            }
        },
        beforeRouteEnter (to, from, next) {
            next(vm => {
                vm.init()
            })
        }
    }
</script>

<style>
</style>
